﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BankSystem
{
    internal class ATM
    {
        private List<Bank> _banks;

        public ATM()
        {
            _banks = new List<Bank>();
        }

        public void AddBank(Bank bank) { 
            _banks.Add(bank);
        }

        public List<Bank> Banks
        {
            get => _banks;
        }

        public String AddAccout(String bankName, String password) {
            return _banks.Find(x => bankName == x.Name).AddAccount(password);
        }

        public Boolean CheckAccount(String bankName,String accountNumber, String password)
        {
            return _banks.Find(x => x.Name == bankName).CheckAccount(accountNumber, password);
        }

        public void SaveMoney(String bankName, String accountNumber, int amount)
        {
            _banks.Find(x => x.Name == bankName).SetBalance(accountNumber, 1, amount);
        }

        public void WithDrawMoney(String bankName, String accountNumber, int amount)
        {
            _banks.Find(x => x.Name == bankName).SetBalance(accountNumber, -1, amount);
        }
    }
}
